<!DOCTYPE>
<html>
@include('common.head')
<body>
	<!--header-->
	@include('common.navbar')
	<!-- header end -->
	<meta name="csrf-token" content="{{ csrf_token() }}">
	<div class="page-container">
	  <div class="page-content" id="mainContents">
	  	<div class="container-fluid">
		<div class="row-fluid clearfix">
	    	<!-- BEGIN STYLE CUSTOMIZER -->
	        <div class="span12">
	          <h3 class="page-title"> 订单管理  </h3>
	          <ul class="breadcrumb">
	            <li> <i class="icon-home"></i> <a href="index.html">首页</a> <i class="icon-angle-right"></i> </li>
	            <li><a href="javascript:;">订单列表</a></li>
	          </ul>
	        </div>
	        <!-- END PAGE TITLE & BREADCRUMB-->
	    </div>
		<!-- BEGIN PAGE CONTENT-->

		<div class="row-fluid">
			<div class="tabbable tabbable-custom tabbable-full-width">

				<ul class="nav nav-tabs">
					<li @if ($_GET['s'] == '10')class="active"@endif><a href="/order/list?s=10">合同处理<span>({{$rs['statistics']['count_10']}})</span></a></li>
					<li @if ($_GET['s'] == '20')class="active"@endif><a href="/order/list?s=20">待上传<span>({{$rs['statistics']['count_20']}})</span></a></li>
					<li @if ($_GET['s'] == '30')class="active"@endif><a href="/order/list?s=30">待认证<span>({{$rs['statistics']['count_30']}})</span></a></li>
					<li @if ($_GET['s'] == '40')class="active"@endif><a href="/order/list?s=40">待OA审核<span>({{$rs['statistics']['count_40']}})</span></a></li>
					<li @if ($_GET['s'] == '50')class="active"@endif><a href="/order/list?s=50">待支付<span>({{$rs['statistics']['count_50']}})</span></a></li>
					<li @if ($_GET['s'] == '60')class="active"@endif><a href="/order/list?s=60">待发货<span>({{$rs['statistics']['count_60']}})</span></a></li>
					<li @if ($_GET['s'] == '70')class="active"@endif><a href="/order/list?s=70">待收货<span>({{$rs['statistics']['count_70']}})</span></a></li>
					<li @if ($_GET['s'] == '80')class="active"@endif><a href="/order/list?s=80">已完成<span>({{$rs['statistics']['count_80']}})</span> </a></li>
					<li @if ($_GET['s'] == '90')class="active"@endif><a href="/order/list?s=90">已取消<span>({{$rs['statistics']['count_90']}})</span> </a></li>
					<li @if ($_GET['s'] == 'all')class="active"@endif><a href="/order/list?s=all">全部<span>({{$rs['statistics']['count_all']}})</span> </a></li>
				</ul>

				<div class="tab-content">
					<!--合同处理-->
					<div id="tab_1_12" class="tab-pane active">
						<div class="row-fluid margin-bottom-20">
							<div class="span12">
								<!-- BEGIN EXAMPLE TABLE PORTLET-->
								<div class="portlet box light-grey">
									<div class="portlet-body">
										<div class="clearfix">
											<div class="btn-group">
												<!--<button id="sample_add_1" class="btn btn-success">
												新增订单
												</button>	-->
												<a href="/" id="sample_add_1" class="btn btn-success">
												新增订单
												</a>
											</div>
											<div class="btn-group">
												<button id="sample_edit_2" class="btn btn-primary">
												编辑订单
												</button>
											</div>
											<div class="btn-group">
												<button id="sample_agin_3" class="btn btn-default">
												再来一单
												</button>
											</div>
											<div class="btn-group">
												<button id="sample_cancelord" class="btn btn-danger">
												取消订单
												</button>
											</div>
											<div class="btn-group">
												<button id="sample_excel_5" class="btn btn-info">
												导出Excel
												</button>
											</div>
											<div class="btn-group">
												<button id="sample_history" class="btn btn-warning">
												历史记录
												</button>
											</div>
										</div>
										<div class="ordertball table-responsive margin-bottom-20">
										    <table class="table table-bordered tablelist" id="dataTableDetail">
							                    <thead class="tbhead">
								                    <tr>
								                    	<th>
								                    		<label class="frstrate">
												    			<input type="checkbox"class="checkson SelectAllImg" />
												    			<img src="{{URL::asset('static/images/c_checkbox_off.png')}}"/>
												    		</label>
								                    	</th>
								                        <th class="t1">
								                        	<p>订单编号</p>
								                        	<div class="controls">
																<input placeholder="请输入订单编号" value="@if (isset($_GET['order_id'])){{$_GET['order_id']}}@endif" class="input-control putw1 c-orderid" type="text" name="order_id">
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>订单类型</p>
								                        	<div class="controls">
																<select class="input-control selwd1 c-orderkind" name="property">
																	<option></option>
																	<option value="normal" @if (isset($_GET['property']) && $_GET['property'] == 'normal')selected="selected"@endif>普通订单</option>
																	<option value="detonate" @if (isset($_GET['property']) && $_GET['property'] == 'detonate')selected="selected"@endif>易制爆订单</option>
																	<option value="poison" @if (isset($_GET['property']) && $_GET['property'] == 'poison')selected="selected"@endif>易制毒订单</option>
																</select>
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>客户名称</p>
								                        	<div class="controls">
																<input placeholder="请输入客户名称" value="@if (isset($_GET['cust_name'])){{$_GET['cust_name']}}@endif" class="input-control putw1 c-orderid" type="text" name="cust_name">
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>收货人员</p>
								                        	<div class="controls">
																<input placeholder="请输入收货人员" value="@if (isset($_GET['name'])){{$_GET['name']}}@endif" class="input-control putw1 c-officer" type="text" name="name">
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>订单总额</p>
								                        	<div class="controls">
																<input placeholder="请输入名单总额" value="@if (isset($_GET['total_price'])){{$_GET['total_price']}}@endif" class="input-control putw1 c-ordertotal" type="text" name="total_price">
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>已付金额</p>
								                        	<div class="controls">
																<input placeholder="请输入已付金额" value="@if (isset($_GET['already_pay'])){{$_GET['already_pay']}}@endif" class="input-control putw2 c-overpay" type="text" name="already_pay">
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>配送方式</p>
								                        	<div class="controls">
																<select class="input-control selwd1 c-distwap" name="deliver">
																	<option></option>
																	@foreach (config('order.order.deliver') as $deliver)
																		<option @if (isset($_GET['deliver']) && $_GET['deliver'] == $loop->index)selected="selected"@endif value="{{$loop->index}}" data-val="{{$loop->index}}">{{$deliver}}</option>
																	@endforeach
																</select>
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>下单时间</p>
								                        	<div class="controls">
								                        		<input placeholder="请输入开始时间" value="@if (isset($_GET['stime'])){{$_GET['stime']}}@endif" class="input-control putw1 c-begintime" type="text" name="beginTime" id="beginTime">
								                        		-
								                        		<input placeholder="请输入结束时间" value="@if (isset($_GET['etime'])){{$_GET['etime']}}@endif" class="input-control putw1 c-endtime" type="text" name="endTime" id="endTime">
								                        	</div>
								                        </th>
								                        <th class="t1">
								                        	<p>业务人员</p>
								                        	<div class="controls">
								                        		<input placeholder="请输入业务人员" class="input-control putw1 c-ordertotal" type="text" name="clerk">
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>订单状态</p>
								                        	<div class="controls">
																<select class="input-control selwd1 c-status" name="orderStatus">
																	<option value="1">待上传</option>
																	<option value="10">待认证</option>
																	<option value="20">待客审</option>
																	<option value="30">待支付</option>
																	<option value="40">待发货</option>
																	<option value="50">待收货</option>
																	<option value="60">已完成</option>
																	<option value="70">已取消</option>
																	<option value="80">已退货</option>
																	<option value="all">全部</option>
																</select>
															</div>
								                        </th>
								                        <th class="t1">
								                        	<p>操作</p>
								                        	<div class="controls lastrate">
								                        		<input class="input-control putw2" type="hidden" readonly>
															</div>
								                        </th>
								                    </tr>
							                    </thead>
							                    <tbody class="tbbody">
							                    	@foreach ($rs['list'] as $data)
								                    <tr>
								                    	<td>
								                    		<label>
												    			<input type="checkbox" class="checkson checkbox_child"/>
												    			<img src="{{URL::asset('static/images/c_checkbox_off.png')}}"/>
												    		</label>
														</td>
								                        <td>{{$data->order_id}}</td>
								                        <td>
								                        	@switch($data->property)
															    @case('detonate')
															        易制爆
															        @break
															    @case('poison')
															        易制毒
															        @break
															    @default
															        普通
															@endswitch
								                        </td>
								                        <td>{{$data->cust_name}}</td>
								                        <td>{{$data->name}}</td>
								                        <td>{{$data->total_price}}</td>
								                        <td>{{$data->already_pay}}</td>
								                        <td>{{config("order.order.deliver.$data->deliver")}}</td>
								                        <td>{{date('Y-m-d H:i:s',$data->create_time)}}</td>
								                        <td>{{$data->clerk}}</td>
								                        <td>
								                        	@if($data->status >=0 && $data->status < 10)
								                        	合同处理
								                        	@endif
								                        	@if($data->status >=10 && $data->status < 20)
								                        	待上传
								                        	@endif
								                        	@if($data->status >=20 && $data->status < 30)
								                        	待认证
								                        	@endif
								                        	@if($data->status >=30 && $data->status < 40)
								                        	待OA审核
								                        	@endif
								                        	@if($data->status >=40 && $data->status < 50)
								                        	待支付
								                        	@endif
								                        	@if($data->status >=50 && $data->status < 60)
								                        	待发货
								                        	@endif
								                        	@if($data->status >=60 && $data->status < 70)
								                        	待收货
								                        	@endif
								                        	@if($data->status >=70 && $data->status < 80)
								                        	已完成
								                        	@endif
								                        	@if($data->status >=80 && $data->status < 90)
								                        	已取消
								                        	@endif
								                        </td>
								                        <td class="lasttd">
								                        	@include('order.order_status_opt')
								                        </td>
								                    </tr>
								                    @endforeach
							                    </tbody>
							               </table>
										</div>
										
						               <div class="row-fluid">
							               	<div class="span6"><div class="dataTables_info" id="sample_editable_1_info">共{{$rs['size']}}条数据</div></div>
							               	<div class="span6">
							               		<div class="dataTables_paginate paging_bootstrap pagination">
						               			 	<div class="chnumer">
					               			 			<span>显示数目:</span>
					               			 			<span class="spel">
					               			 				<select class="" name="shNumer">
																<option @if (isset($_GET['limit']) && $_GET['limit'] == '10')selected="selected"@endif value="10">10</option>
																<option @if (isset($_GET['limit']) && $_GET['limit'] == '20')selected="selected"@endif value="20">20</option>
																<option @if (isset($_GET['limit']) && $_GET['limit'] == '30')selected="selected"@endif value="30">30</option>
																<option @if (isset($_GET['limit']) && $_GET['limit'] == '50')selected="selected"@endif value="50">50</option>
															</select>
					               			 			</span>
														
						               			 	</div>
						               			 	{{ $rs['page'] }}
							               			<div class="clearfix"></div>
							               		</div>
							               	</div>
							            </div>
									</div>
								</div>
								<!-- END EXAMPLE TABLE PORTLET-->
							</div>
						</div>
					</div>
					
					<!--end tab-pane-->

				</div>

			</div>

			<!--end tabbable-->           

		</div>

		<!-- END PAGE CONTENT-->

	</div>
	  </div>
	</div>
	
	<!-- footer -->
	@include('common.footer')
	<!--2018-7-30 begin-->
    <!--取消订单弹窗-->
    <div class="modelcancel j-cancelModel hide">
    	<div class="portlet-body">
			<!-- BEGIN FORM-->
			<form action="#" id="form_cancel" class="form-horizontal padding-top-20">
    			<div class="control-group">
					<label class="control-label">取消订单理由<span class="required">*</span></label>
					<div class="controls">
						<input type="text" class="span3 m-wrap c-kreason" autocomplete="off" name="selfName"  placeholder="请输入取消原因">
					</div>
				</div>
	    	</form>
	   </div>
    </div>

    <div class="cancelcontract j-cancelcontract hide">
    	<div class="portlet-body">
			<!-- BEGIN FORM-->
			<form action="#" id="form_cancel" class="form-horizontal padding-top-20">
    			<div class="control-group">
					<label class="control-label">选择和同类型<span class="required">*</span></label>
					<div class="controls">
						<select class="span6 m-wrap j-pactchoose" id="cancel_contract_type">
							<option value="">请选择合同</option>
							@foreach (config('order.order.contract_type') as $contract_type)
								<option @if (isset($rs['material']->contract_type) && $rs['material']->contract_type == $loop->index)selected="selected"@endif value="{{$loop->index}}">{{$contract_type}}</option>
							@endforeach
						</select>
					</div>
				</div>
	    	</form>
	   </div>
    </div>
    
    <!--历史记录弹窗-->
    <div class="modelhist j-histModel hide">
    	<div class="portlet-body">
			<div class="orderhist margin-bottom-20">
				<table class="table table-bordered tablelist" id="dataTableDetail">
	                <thead class="tbhead">
	                    <tr>
	                        <th class="t1">
	                        	<p>操作时间</p>
	                        </th>
	                        <th class="t1">
	                        	<p>操作人</p>
	                        </th>
	                        <th class="t1">
	                        	<p>描述</p>
	                        </th>
	                        <th class="t1">
	                        	<p>备注</p>
	                        </th>
	                    </tr>
	                </thead>
	                <tbody class="tbbody">
	                    <tr>
	                        <td>2018-07-03</td>
	                        <td>系统管理员</td>
	                        <td>取消订单</td>
	                        <td>库存不足，取消订单</td>
	                    </tr>
	                    <tr>
	                        <td>2018-07-03</td>
	                        <td>上海西陇</td>
	                        <td>编辑订单</td>
	                        <td>库存不足，取消订单</td>
	                    </tr>
	                    
	                    <tr>
	                        <td>2018-07-03</td>
	                        <td>系统管理员</td>
	                        <td>取消订单</td>
	                        <td>库存不足，取消订单1</td>
	                    </tr>
	                </tbody>
	           </table>
	        </div>
            <div class="row-fluid">
               	<div class="span6"><div class="dataTables_info" id="sample_editable_1_info">共2条数据</div></div>
               	<div class="span6">
               		<div class="dataTables_paginate paging_bootstrap pagination">
               			<ul>
               				<li class="prev disabled">
               					<a href="#">← <span class="hidden-480">上一页</span></a>
               				</li>
               				<li class="active">
               					<a href="#">1</a>
               				</li>
               				<li>
               					<a href="#">2</a>
               				</li>
               				<li class="next">
               					<a href="#"><span class="hidden-480">下一页</span> → </a></li>
               			</ul>
               		</div>
               	</div>
            </div>
	   </div>
    </div>
    <!--选择合同 -弹窗-->
</div>
 
    <!--时间-->
	<script src="{{URL::asset('static/js/bootstrap/bootstrap-datepicker.min.js')}}"></script>
	<script src="{{URL::asset('static/js/bootstrap/bootstrap-datepicker.zh-CN.min.js')}}"></script>
	<link rel="stylesheet" href="{{URL::asset('static/style/bootstrap/bootstrap-datepicker3.standalone.min.css')}}">
	
	<script>
		/*
			* name:时间范围控件
			* start:起始时间表单id值
			* end:结束时间表单id值
			*
    	*/
    	$("[name='order_id']").blur(function(){
    		search_list();
		});
		$("[name='property']").change(function(){
  			search_list();
		});
		$("[name='cust_name']").blur(function(){
  			search_list();
		});
		$("[name='name']").blur(function(){
  			search_list();
		});
		$("[name='total_price']").blur(function(){
  			search_list();
		});
		$("[name='already_pay']").blur(function(){
  			search_list();
		});
		$("[name='deliver']").change(function(){
  			search_list();
		});
		$("[name='clerk']").blur(function(){
  			search_list();
		});
		$("[name='shNumer']").change(function(){
  			search_list();
		});

		var search_list = function(){

			var filter = '';
			var url = '/order/list?1';

			var page = '{{@$_GET['page']}}';
			var order_id = $("[name='order_id']").val();
			var property = $("[name='property']").val();
			var cust_name = $("[name='cust_name']").val();
			var name = $("[name='name']").val();
			var total_price = $("[name='total_price']").val();
			var already_pay = $("[name='already_pay']").val();
			var deliver = $("[name='deliver']").val();
			var clerk = $("[name='clerk']").val();
			var stime = $("[name='beginTime']").val();
			var etime = $("[name='endTime']").val();
			var shNumer = $("[name='shNumer']").val();
			if(page){
                filter += '&page='+page;
            }
            if(shNumer){
                filter += '&limit='+shNumer;
            }
            if(order_id){
                filter += '&order_id='+order_id;
            }
            if(property){
                filter += '&property='+property;
            }
            if(cust_name){
                filter += '&cust_name='+cust_name;
            }
            if(name){
                filter += '&name='+name;
            }
            if(total_price){
                filter += '&total_price='+total_price;
            }
            if(already_pay){
                filter += '&already_pay='+already_pay;
            }
            if(deliver){
                filter += '&deliver='+deliver;
            }
            if(clerk){
                filter += '&clerk='+clerk;
            }
            if(stime){
                filter += '&stime='+stime;
            }
            if(etime){
                filter += '&etime='+etime;
            }
            // alert(filter);
            window.location.href = url+filter;
		}
		function dataTimeRange(start,end){//日期范围
		    $('#'+start).datetimepicker({
		        todayBtn : "linked",
		        autoclose : true,
		        todayHighlight : true,
		        endDate : new Date(),
		        format:'yyyy-mm-dd hh:ii',
		        language:'zh-CN'
		    }).on('changeDate',function(e){
		        var startTime = e.date;
		        $('#'+end).datetimepicker('setStartDate',startTime);
		        search_list();
		    }).on('hide',function(e){
		        search_list();
		    });
		 
		    //结束时间
		    $('#'+end).datetimepicker({
		        todayBtn : "linked",
		        autoclose : true,
		        todayHighlight : true,
		        endDate : new Date(),
		        format:'yyyy-mm-dd hh:ii',
		        language:'zh-CN'
		    }).on('changeDate',function(e){
		        var endTime = e.date;
		        $('#'+start).datetimepicker('setEndDate',endTime);
		        search_list();
		    }).on('hide',function(e){
		        search_list();
		    });
		} 
		dataTimeRange("beginTime","endTime");
		function showBigPic(pic){
			if(pic){
				var img = '<img src="'+pic+'" style="max-width:640px; max-height:640px" class="upedimg">';
				layer.open({
				  title:'查看',
				  type: 1,
				  // skin: 'layui-layer-demo', //样式类名
				  offset: 't',
				  closeBtn: 0, //不显示关闭按钮
				  anim: 5,
				  area: ['640px', '640px'], //宽高
				  shadeClose: true, //开启遮罩关闭
				  content: img
				});
			}
		}

	</script>	
</body>

</html>